﻿using SqlSugar;

namespace ProjectScheduling.models
{
    [SugarTable("Projects")]
    public class Projects : BClass
    {
        /// <summary>
        /// 员工数量
        /// </summary>
        public int StaffCount { get; set; } = 2;
        /// <summary>
        /// 项目周期（天数）
        /// </summary>
        public int Days { get; set; } = 2;
        public string? Name { get; set; }
        public string? Description { get; set; }
        public string? Address { get; set; }
        public int ProjectTypeId { get; set; }
        [Navigate(NavigateType.OneToOne, nameof(ProjectTypeId), nameof(ProjectTypes.Id))]
        public ProjectTypes? ProjectType { get; set; }
        [SugarColumn(IsIgnore = true)]
        public (int id, string name, int timehours)? ProjectTypeMessage { get; set; }
        public DateTime PlanStartDate { get; set; }
        public DateTime PlanEndDate { get; set; }
        public DateTime FromDate { get; set; }
        public DateTime ToDate { get; set; }
        public DateTime CreateDate { get; set; }
        public int CreatorId { get; set; }
        [Navigate(NavigateType.OneToOne, nameof(CreatorId))]
        public Users? Creator { get; set; }
        public Enum_ProjectState State { get; set; }
        public DateTime? StopTime { get; set; }
        [SugarColumn(IsIgnore = true)]
        public List<(int id, string name)>? Staffs { get; set; }

        [Navigate(NavigateType.OneToMany, nameof(ProjectStaff.ProjectId))]
        public List<ProjectStaff>? StaffsList { get; set; }
        public string? CustomerName { get; set; }
        public string? Linker { get; set; }
        public string? Phone { get; set; }
        public string? ContractState { get; set; }
        public string? ApproveState { get; set; }
        public int SalespersonId { get; set; }
        [Navigate(NavigateType.OneToOne, nameof(SalespersonId))]
        public Sales? Sales { get; set; }
        
        public int Rate { get; set; } = 0;

        /// <summary>
        /// 休息日
        /// </summary>
        public string? RestDate { get; set; }
        [SugarColumn(IsIgnore = true)]
        public string ProjectTypeName
        {
            get
            {
                return ProjectType?.Name ?? "";
            }
        }
        [SugarColumn(IsIgnore = true)]
        public string CreatorName
        {
            get
            {
                return Creator?.Name ?? "";
            }
        }
        /// <summary>
        /// 项目归属 系统内、系统外
        /// </summary>
        public string? OwnerShip
        {
            get;set;
        }
        [Navigate(NavigateType.OneToMany,nameof(PreparedData.ProjectId))]
        public List<PreparedData>? PreparedDatas { get; set; }
        /// <summary>
        /// 人天消耗
        /// </summary>
        public int StaffDays { get; set; }
        /// <summary>
        /// 工作量评分
        /// </summary>
        public int Score { get; set; }
    }
}
